package com.hu.jie.mywallpager.activity;

import android.content.Intent;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import com.hu.jie.mywallpager.R;
import com.hu.jie.mywallpager.fragment.HomeFragment;

//复用第一个碎片
public class PageActivity extends AppCompatActivity {
    private String URL_HOME;
    private String URL_HOT;
    private String URL_RANDOM;
    private TextView tv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_page);
        tv = (TextView) findViewById(R.id.textView);
        Intent intent = getIntent();
        Bundle b = intent.getExtras();
        String title = b.getString("title");
        URL_HOME = b.getString("home");
        URL_HOT = b.getString("hot");
        URL_RANDOM = b.getString("random");
        tv.setText(title);
        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        HomeFragment fragment = HomeFragment.newInstance(title,URL_HOME,URL_HOT,URL_RANDOM);
        ft.add(R.id.fragmenthome,fragment);
        ft.commit();
    }












}

